This pull request enhances the /orders API endpoint by improving its search capabilities, updating the response structure, and adding tests to ensure correct functionality. #82
Merged
goldlabelapps merged 2 commits intomasterfrom Apr 11, 2026
Conversation
Refactor GET /orders to accept an aliased query param `s` (instead of `search`) and perform a case-insensitive partial match against name, description, and categories. Builds SQL WHERE clauses using LOWER(... ) LIKE %s, constructs a single lowered wildcard param and extends the query params accordingly. Also includes the provided search string in the response under `search.searchStr` and removes extraneous blank lines and an outdated comment about non-existent first_name/last_name columns.
Add tests/tests_orders.py with pytest tests using FastAPI TestClient to exercise the /orders endpoint. Tests validate response structure (meta, pagination, data, search), ensure data is a list and contains expected item keys when present, assert meta fields (severity and title), and verify handling of the s search parameter. This helps catch regressions in paginated order reads and search behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The main changes include switching to a new search query parameter, expanding the searchable fields, and introducing automated tests for the endpoint.
API improvements:
searchtos(with alias support) for clarity and consistency.name,description, andcategoriesfields.searchobject with the search string used, improving client-side clarity.Testing:
tests/test_orders.pyto verify the/ordersendpoint, including checks for the response structure, correct handling of the search parameter, and validation of returned data fields.